
#include <winsock2.h>
#include <ev_port.h>
#include <stdio.h> // for puts


// every watcher type has its own typedef'd struct
// with the name ev_TYPE
ev_timer timeout_watcher;


// another callback, this time for a time-out
static void timeout_cb (EV_P_ ev_timer *w, int revents)
{
	puts ("timeout\n");

	// this causes the innermost ev_loop to stop iterating
	//ev_unloop (EV_A_ EVUNLOOP_ONE);
}


void syserr_print(const char *msg)
{
	printf("%s\n", msg);
}


int main (void)
{
	// use the default event loop unless you have special needs
	struct ev_loop *loop;

    WORD ver = MAKEWORD( 2, 2 );
	WSADATA data;
    WSAStartup(ver, &data);

	loop = ev_default_loop (0);

	// initialise a timer watcher, then start it
	// simple non-repeating 5.5 second timeout
	ev_timer_init (&timeout_watcher, timeout_cb, 1.5, 1.5);
	ev_timer_start (loop, &timeout_watcher);

	ev_set_syserr_cb(syserr_print);

	// now wait for events to arrive
	ev_loop (loop, 0);

	// unloop was called, so exit
	return 0;
}

